#ifndef svl_TEvents_H
#define svl_TEvents_H

#include "svl.h"

namespace svl {

///////////////////////////////////////////////////////////////////////////////
struct TEvents;
struct TEventsList;
///////////////////////////////////////////////////////////////////////////////

struct TEventsItem : public TDList_Object
{
  TEvents     &Events;
  TEventsList &EventsList;
  //
  TEventsItem(TEvents &E,TEventsList &L) : Events(E),EventsList(L) {}
};

///////////////////////////////////////////////////////////////////////////////

struct TEvents : public TDebug
{
  struct TI
  {
    TI(TEventsList &V);
    TEvents *GetPrev();
  private:
    TDList_Iterator i;
  };

  struct TParam
  {
    TParam(TEventsList &EventsList) : i(EventsList) {}
    TEvents *GetPrev() { return i.GetPrev(); }
  private:  
    TI i;
  };
};

///////////////////////////////////////////////////////////////////////////////

struct TEventsList : public TDebug
{
  TEventsList(TEvents &EventsDefault);
  //
  void Link  (TEvents &V);
  void Unlink(TEvents &V);
  //
  TEvents     &GetBot();
  TEventsItem *Search(TEvents &V);

private:
  TDList list;
  friend TEvents;
  friend TEvents::TI;
};

///////////////////////////////////////////////////////////////////////////////
}

#endif
